package com.gxlu.ms.base.result;

import java.util.Map;

/**
 * FinalResult 用于Service 结果集
 * @author andy.lhc
 * @date 2018/3/16
 */
public class FinalResult<T> extends Result<T> {


    public FinalResult(){
        super();
    }

    public static  FinalResult success(){
        FinalResult result = new FinalResult();
        result.setStatus(true);
        result.setCode(1);
        return result;
    }

    public static <T> FinalResult success(T t){
        FinalResult result = new FinalResult();
        result.setStatus(true);
        result.setCode(1);
        result.setData(t);
        return result;
    }

    public static FinalResult success(Map<String,Object> feature){
        FinalResult result = new FinalResult();
        result.setStatus(true);
        result.setCode(1);
        result.setFeature(feature);
        return result;
    }

    public static FinalResult of(boolean status,int code,String msg){
        FinalResult result = new FinalResult();
        result.setStatus(status);
        result.setCode(code);
        result.setMsg(msg);
        return result ;
    }

    public static FinalResult fail(int code,String msg){
        FinalResult result = new FinalResult();
        result.setStatus(false);
        result.setCode(code);
        result.setMsg(msg);
        return result ;
    }

    public static <T> FinalResult fail(T data){
        FinalResult result = new FinalResult();
        result.setStatus(false);
        result.setData(data);
        return result ;
    }

    public static FinalResult fail(int code,String msg,Map<String,Object> feature){
        FinalResult result = new FinalResult();
        result.setStatus(false);
        result.setCode(code);
        result.setMsg(msg);
        result.setFeature(feature);
        return result ;
    }


}
